#include <stdio.h>
#include <string.h>

int strStr(char* haystack, char* needle)
{
    int hlen = strlen(haystack);
    int nlen = strlen(needle);
    int pos = 0;
    for(int i = 0;i < hlen;i++)
    {
        if(haystack[i] == needle[pos])
        {
            pos++;
        }
        else
        {
            pos = 0;
        }
        if(pos == nlen)
        {
            return i - nlen + 1;
        }
    }
    return -1;
}

int main()
{
    char haystack[] = "helsadbhj";
    char needle[] = "sdj";
    int n = strStr(haystack,needle);
    printf("%d\n",n);
    return 0;
}